#pragma once
#include <string>
#include <vector>
#include "Example.h"

enum DataFormat {LIBSVM};

class MemoryDataStore
{
protected:
  std::string m_DataFile;
  std::vector<Example> m_Examples;
  bool m_IsLabeled;
public:
  MemoryDataStore(const std::string& dataFile, DataFormat format
    = LIBSVM, int hint = 0);
  virtual ~MemoryDataStore(void);

  int GetExampleCount() const { return m_Examples.size(); }
  bool GetIsLabeled() const { return m_IsLabeled; }
  const Example& GetNextExample() const { return m_Examples[rand() % m_Examples.size()]; }
  const std::vector<Example>& GetExamples() const { return m_Examples; }
protected:
  void readLibSVM(int hint);
  void scanLibSVM(int& nExample, int& nDim, bool& isLabeled);
  bool readLibSVMRow(std::ifstream& input, arma::sp_mat& x, double& y) const;
};

